#ifndef MOUSE_H
#define MOUSE_H

#include "pictor.h"
#include <dos.h>


/* Handy macros to have! */
#define BIT(_x) (1 << (_x))
#define mousetoPLrows(_y) (_y / (200 / _PL_rows)) + 1
#define mousetoPLcolumns(_x) (_x / (640 / _PL_columns)) + 1

#define NO_BUTTON_PRESSED 0
#define LEFT_BUTTON_PRESSED 1
#define RIGHT_BUTTON_PRESSED 2
#define MIDDLE_BUTTON_PRESSED 3

/* Both initialization and end cleanup are the same. */
#define endmouse() initmouse()
//#define LEFT_BUTTON_RELEASED BIT(4)
//#define RIGHT_BUTTON_RELEASED BIT(5)
//#define MIDDLE_BUTTON_RELEASED BIT(6)

//#define LEFT_BUTTON_CLICKED (LEFT_BUTTON_PRESSED || NO_BUTTON_PRESSED)
//#define RIGHT_BUTTON_CLICKED (RIGHT_BUTTON_PRESSED || NO_BUTTON_PRESSED)
//#define MIDDLE_BUTTON_CLICKED (MIDDLE_BUTTON_PRESSED || NO_BUTTON_PRESSED)

/* Future: Define routines for scroll wheel mice. */

extern int _PL_rows;
extern int _PL_columns;

/* Doesn't currently do anything- but makes sure mouse routines skip
 * or fail if mouse is not present. At worst, having this set to the
 * incorrect value (i.e. TRUE when mouse isn't present) should only 
 * cause minor graphical issues. */
extern int _PL_mousepresent;

int initmouse();
int inittimer();
void showmouse();
void hidemouse();
void mousestatus();

int __cdecl querykeyboard();


//void (__interrupt __far *old_timer_int_1ch)();

/* Far modifier may not be necessary depending on memory model used. */
void __interrupt __far pictor_mouse_timer_int_1ch();

#define hook_timer_for_mouse() 	old_timer_int_1ch = _dos_getvect(0x1C); _dos_setvect(0x1C, pictor_mouse_timer_int_1ch)
#define unhook_timer_for_mouse() _dos_setvect(0x1C, old_timer_int_1ch)

#endif
